home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / windows5 / wedl20.zip / WEDL.H < prev    next >
Text File  |  1991-05-01  |  19KB  |  369 lines

  1.  
  2. /*---------------------------------------------------------------------------*/
  3. /*                                                                           */
  4. /*          WEDL (tm) - Windows Enhanced Dialog Library                      */
  5. /*          Copyright (c) 1991-1992, Nemisoft, Inc.                          */
  6. /*          All Rights Reserved                                              */
  7. /*          Module:  WEDL.H                                                  */
  8. /*                                                                           */
  9. /*---------------------------------------------------------------------------*/
  10.  
  11. #if !defined( __WEDL_H )
  12.     #define __WEDL_H
  13.  
  14. /*---------------------------------------------------------------------------*/
  15.  
  16. /* Windows 3.0 SDK compatibility */
  17.  
  18. #if !defined( WINAPI )
  19.     #define WINAPI FAR PASCAL
  20.     typedef unsigned int UINT;
  21.     typedef UINT WPARAM;
  22.     typedef HANDLE HINSTANCE;
  23.     typedef LONG (WINAPI* WNDPROC)(HWND, UINT, WPARAM, LONG);
  24. #endif
  25.  
  26. /*---------------------------------------------------------------------------*/
  27.  
  28. /* form feature definitions */
  29.  
  30. #define FMF_NONE        0L      /* no features specified                  */
  31. #define FMF_OVERTYPE    1L      /* set Insert mode off by default         */
  32. #define FMF_UPDATE      2L      /* set all controls in update mode        */
  33. #define FMF_VKEYPRES    4L      /* perform validation after each keypress */
  34. #define FMF_VLEAVFLD    8L      /* do validation when user leaves field   */
  35. #define FMF_NOSELECT    16L     /* no auto-select of fields upon focus    */
  36.  
  37. /*---------------------------------------------------------------------------*/
  38.  
  39. /* field feature definitions */
  40.  
  41. #define FDF_NONE        0L      /* no features specified                  */
  42. #define FDF_COMPLETE    1L      /* field must be complete                 */
  43. #define FDF_NOTBLANK    2L      /* field cannot be blank                  */
  44. #define FDF_NOTZERO     4L      /* field cannot be zero                   */
  45. #define FDF_NOTEDIT     8L      /* field cannot be edited                 */
  46. #define FDF_MUSTEDIT    16L     /* field must be edited                   */
  47. #define FDF_UPDATE      32L     /* update existing data                   */
  48. #define FDF_NOSELECT    64L     /* no auto-select of field upon focus     */
  49. #define FDF_SPCFILL     128L    /* space-fill field from right            */
  50. #define FDF_ZEROFILL    256L    /* zero-fill numeric field from left      */
  51. #define FDF_BLNKZERO    512L    /* blank numeric field if equal to zero   */
  52. #define FDF_BLNKNEZ     1024L   /* blank not equal zero (numeric field)   */
  53. #define FDF_PHYSICAL    2048L   /* read/write data in physical format     */
  54. #define FDF_UPPER       4096L   /* convert characters to UPPERCASE        */
  55. #define FDF_LOWER       8192L   /* convert characters to lowercase        */
  56. #define FDF_PROPER      16384L  /* convert characters to Proper Case      */
  57. #define FDF_NUMERIC     32768L  /* standard numeric field                 */
  58. #define FDF_CALCNUM     65536L  /* calculator-style numeric field         */
  59. #define FDF_VKEYPRES    131072L /* perform validation after each keypress */
  60. #define FDF_VLEAVFLD    262144L /* do validation when user leaves field   */
  61. #define FDF_COMBO       524288L /* field belongs to a combo box           */
  62.  
  63. /*---------------------------------------------------------------------------*/
  64.  
  65. /* enable-link condition definitions */
  66.  
  67. #define ELC_BLANK       1L      /* field is blank                    */
  68. #define ELC_ZERO        2L      /* field contains a zero value       */
  69. #define ELC_EDITED      3L      /* field has been edited by the user */
  70. #define ELC_CHECKED     4L      /* button is checked                 */
  71.  
  72. /*---------------------------------------------------------------------------*/
  73.  
  74. /* field data type definitions */
  75.  
  76. #define FDT_NULL        0       /* 'pdata' pointer == NULL      */
  77. #define FDT_STRING      1       /* character string             */
  78. #define FDT_SHORT       2       /* 16-bit signed integer        */
  79. #define FDT_USHORT      3       /* 16-bit unsigned integer      */
  80. #define FDT_INTEGER     4       /* signed integer               */
  81. #define FDT_UNSIGNED    5       /* unsigned integer             */
  82. #define FDT_LONG        6       /* 32-bit signed long integer   */
  83. #define FDT_ULONG       7       /* 32-bit unsigned long integer */
  84. #define FDT_FLOAT       8       /* single precision real number */
  85. #define FDT_DOUBLE      9       /* double precision real number */
  86.  
  87. /*---------------------------------------------------------------------------*/
  88.  
  89. /* button feature definitions */
  90.  
  91. #define BTF_NONE        0L      /* no features specified                    */
  92. #define BTF_CHECKED     1L      /* button is initially checked              */
  93. #define BTF_GRAYED      2L      /* button is initially grayed               */
  94. #define BTF_UPDATE      4L      /* button is initialize according to pdata  */
  95. #define BTF_GENERIC     8L      /* button record holds generic control info */
  96. #define BTF_IDOK        16L     /* button is the "OK" button                */
  97. #define BTF_IDCANCEL    32L     /* button is the "Cancel" button            */
  98.  
  99. /*---------------------------------------------------------------------------*/
  100.  
  101. /* key status message definitions */
  102.  
  103. #define KSM_INSERT      0       /* Insert key status message    */
  104. #define KSM_CAPSLOCK    1       /* CapsLock key status message  */
  105. #define KSM_NUMLOCK     2       /* NumLock key status message   */
  106.  
  107. /*---------------------------------------------------------------------------*/
  108.  
  109. /* internal field error values (don't use these for your own error values) */
  110.  
  111. #define ERV_BLANK       27701   /* field is blank                       */
  112. #define ERV_INCOMPL     27702   /* field is incomplete                  */
  113. #define ERV_INVCHAR     27703   /* field contains invalid character(s)  */
  114. #define ERV_NOTEDIT     27704   /* user tried to edit noneditable field */
  115. #define ERV_UNEDITED    27705   /* field hasn't been edited             */
  116. #define ERV_ZERO        27706   /* field has a value of zero            */
  117.  
  118. /*---------------------------------------------------------------------------*/
  119.  
  120. /* error event definitions */
  121.  
  122. #define ERE_KEYPRESS    1       /* a key was pressed                 */
  123. #define ERE_LEAVEFLD    2       /* user attempted to leave the field */
  124. #define ERE_SELECTOK    3       /* user attempted to select "OK"     */
  125.  
  126. /*---------------------------------------------------------------------------*/
  127.  
  128. /* definitions of WEDL handles */
  129.  
  130. typedef HANDLE  HFORM;          /* handle of a form record   */
  131. typedef HANDLE  HFIELD;         /* handle of a field record  */
  132. typedef HANDLE  HBUTTON;        /* handle of a button record */
  133.  
  134. /*---------------------------------------------------------------------------*/
  135.  
  136. /* pointer to a validation function (procedure-instance address) */
  137.  
  138. typedef int (WINAPI *PVALFUNC) (HFORM,HFIELD,LPSTR);
  139.  
  140. /* pointer to an error handler function (procedure-instance address) */
  141.  
  142. typedef BOOL (WINAPI *PERRFUNC) (HFORM,HFIELD,int,int,int);
  143.  
  144. /*---------------------------------------------------------------------------*/
  145.  
  146. /* definition of a field record */
  147.  
  148. typedef struct {
  149.     DWORD features;             /* field features                            */
  150.     DWORD help_context;         /* help context ID of help topic for field   */
  151.     LPSTR picture_string;       /* pointer to the field picture string       */
  152.     LPVOID pdata;               /* pointer to data type to write/update      */
  153.     PVALFUNC pvalid_func;       /* proc-instance address of validation func. */
  154.     HWND hcombo;                /* handle of combo box field belongs to      */
  155.     HWND hwnd;                  /* field's window handle                     */
  156.     HFIELD hfield;              /* field's memory handle                     */
  157.     HFIELD hnext_field;         /* handle of next field in linked list       */
  158.     int ctrl_id;                /* dialog control ID of edit control         */
  159.     int data_type;              /* data type pointed to by 'data' parameter  */
  160.     int decimal_position;       /* virtual logical position of decimal point */
  161.     int error_value;            /* unique error value                        */
  162.     int logical_size;           /* logical size of field                     */
  163.     int physical_size;          /* physical size of field                    */
  164.     BOOL has_changed;           /* flag - "field has changed"                */
  165. } FIELD;
  166.  
  167. typedef FIELD *     PFIELD;
  168. typedef FIELD FAR * LPFIELD;
  169.  
  170. /*---------------------------------------------------------------------------*/
  171.  
  172. /* field position information */
  173.  
  174. typedef struct {
  175.     LPSTR ppicture_str_pos;     /* pointer to picture string position      */
  176.     long selection;             /* selection                               */
  177.     int logical_position;       /* logical position                        */
  178.     int physical_position;      /* physical position                       */
  179.     int val_char_occ;           /* validation character occurrence         */
  180.     BOOL to_right_of_dec;       /* position is to the right of the decimal */
  181.     char validation_char;       /* validation character for position       */
  182. } FIELD_POS;
  183.  
  184. typedef FIELD_POS *     PFIELD_POS;
  185. typedef FIELD_POS FAR * LPFIELD_POS;
  186.  
  187. /*---------------------------------------------------------------------------*/
  188.  
  189. /* definition of a form record */
  190.  
  191. typedef struct {
  192.     DWORD features;             /* form features                            */
  193.     PERRFUNC perror_func;       /* proc-instance address of error handler   */
  194.     FARPROC pdialog_proc;       /* address of dialog box's window procedure */
  195.     DWORD help_context;         /* default Windows Help context             */
  196.     LPSTR capslock_offmsg;      /* pointer to CapsLock "off" status message */
  197.     LPSTR capslock_onmsg;       /* pointer to CapsLock "on" status message  */
  198.     LPSTR help_file_name;       /* help file name                           */
  199.     LPSTR insert_offmsg;        /* pointer to Insert "off" status message   */
  200.     LPSTR insert_onmsg;         /* pointer to Insert "on" status message    */
  201.     LPSTR numlock_offmsg;       /* pointer to NumLock "off" status message  */
  202.     LPSTR numlock_onmsg;        /* pointer to NumLock "on" status message   */
  203.     long undo_selection;        /* undo selection                           */
  204.     HANDLE hhead_elink;         /* handle of head enable-link record        */
  205.     HANDLE hproc_array;         /* handle of window procedure array         */
  206.     HANDLE hundo_buffer1;       /* handle of field undo buffer #1           */
  207.     HANDLE hundo_buffer2;       /* handle of field undo buffer #2           */
  208.     HWND hdlg;                  /* form's dialog box window handle          */
  209.     HFORM hform;                /* form's memory handle                     */
  210.     HFORM hnext_form;           /* handle of next form in linked list       */
  211.     HFIELD hcurr_field;         /* handle of current node in field list     */
  212.     HFIELD herror_field;        /* handle of field in error                 */
  213.     HFIELD hhead_field;         /* handle of head node in field list        */
  214.     HBUTTON hhead_button;       /* handle of head node in button list       */
  215.     int cancel_id;              /* control ID of "Cancel" button            */
  216.     int capslock_id;            /* control ID of CapsLock status message    */
  217.     int error_event;            /* event which caused the error             */
  218.     int error_position;         /* logical position of the error            */
  219.     int error_value;            /* error value of field in error            */
  220.     int insert_id;              /* control ID of Insert status message      */
  221.     int numlock_id;             /* control ID of NumLock status message     */
  222.     int num_controls;           /* number of defined controls in form       */
  223.     int ok_id;                  /* control ID of "OK" button                */
  224.     int undo_level;             /* undo level                               */
  225.     BOOL edit_key_pressed;      /* flag - "an editing key was pressed"      */
  226.     BOOL help_invoked;          /* flag - "Windows Help has been invoked"   */
  227.     BOOL insert_mode;           /* flag - "insert mode on"                  */
  228.     BOOL in_error_handler;      /* flag - "in field error handler"          */
  229.     BOOL just_passed_dec;       /* flag - "just passed decimal point"       */
  230.     BOOL pressed_cancel;        /* flag - "Cancel was pressed"              */
  231. } FORM;
  232.  
  233. typedef FORM *     PFORM;
  234. typedef FORM FAR * LPFORM;
  235.  
  236. /*---------------------------------------------------------------------------*/
  237.  
  238. /* definition of a button record */
  239.  
  240. typedef struct {
  241.     DWORD features;             /* button features                          */
  242.     DWORD help_context;         /* help context ID of help topic for button */
  243.     LPINT pdata;                /* pointer to data to initialize/update     */
  244.     HWND hwnd;                  /* button's window handle                   */
  245.     HBUTTON hbutton;            /* handle of button's window                */
  246.     HBUTTON hnext_button;       /* handle of next button in linked list     */
  247.     int ctrl_id;                /* dialog control ID of button              */
  248.     int group_id;               /* group affiliation ID                     */
  249.     int off_value;              /* value stored at 'pdata' if not checked   */
  250.     int on_value;               /* value stored at 'pdata' if checked       */
  251.     BOOL has_changed;           /* flag - "button has changed"              */
  252. } BUTTON;
  253.  
  254. typedef BUTTON *     PBUTTON;
  255. typedef BUTTON FAR * LPBUTTON;
  256.  
  257. /*---------------------------------------------------------------------------*/
  258.  
  259. #if defined(__cplusplus)
  260.     extern "C" {
  261. #endif
  262.  
  263. /* button functions */
  264.  
  265. HBUTTON  WINAPI button_define( HFORM hform, int ctrl_id, LPINT pdata,
  266.                                int group_id, int on_value, int off_value,
  267.                                DWORD features, DWORD help_context );
  268. int      WINAPI button_get_check( HBUTTON hbutton );
  269. HBUTTON  WINAPI button_get_from_ctrl_id( HFORM hform, int ctrl_id );
  270. HBUTTON  WINAPI button_get_from_group( HFORM hform, int group_id );
  271. HBUTTON  WINAPI button_get_from_hwnd( HFORM hform, HWND hWnd );
  272. HWND     WINAPI button_get_hwnd( HBUTTON hbutton );
  273. BOOL     WINAPI button_has_changed( HBUTTON hbutton );
  274. LPBUTTON WINAPI button_lock( HBUTTON hbutton );
  275. int      WINAPI button_set_check( HBUTTON hbutton, int state );
  276. void     WINAPI button_unlock( HBUTTON hbutton );
  277.  
  278. /*---------------------------------------------------------------------------*/
  279.  
  280. /* character manipulation functions */
  281.  
  282. BOOL WINAPI char_is_printable( int ch );
  283. int  WINAPI char_to_lower( int ch );
  284. int  WINAPI char_to_upper( int ch );
  285.  
  286. /*---------------------------------------------------------------------------*/
  287.  
  288. /* field functions */
  289.  
  290. int     WINAPI field_data_to_log( HFIELD hfield, LPSTR pbuf, LPVOID pdata,
  291.                                   int data_type );
  292. HFIELD  WINAPI field_define( HFORM hform, int ctrl_id, LPVOID pdata,
  293.                              int data_type, LPSTR picture_string,
  294.                              DWORD features, PVALFUNC pvalid_func,
  295.                              int error_value, DWORD help_context );
  296. int     WINAPI field_get_character( HFIELD hfield, int position,
  297.                                     BOOL physical );
  298. int     WINAPI field_get_ctrl_id( HFIELD hfield );
  299. HFIELD  WINAPI field_get_from_ctrl_id( HFORM hform, int ctrl_id );
  300. HFIELD  WINAPI field_get_from_hwnd( HFORM hform, HWND hWnd );
  301. HWND    WINAPI field_get_hwnd( HFIELD hfield );
  302. int     WINAPI field_get_pos_info( HFIELD hfield, int logical_position,
  303.                                    LPFIELD_POS pfpos );
  304. int     WINAPI field_get_position( HFIELD hfield, LPFIELD_POS pfpos );
  305. int     WINAPI field_get_text( HFIELD hfield, LPSTR pbuf, BOOL physical );
  306. BOOL    WINAPI field_has_changed( HFIELD hfield );
  307. LPFIELD WINAPI field_lock( HFIELD hfield );
  308. int     WINAPI field_log_to_data( HFIELD hfield, LPSTR pbuf, LPVOID pdata,
  309.                                   int data_type );
  310. int     WINAPI field_log_to_phys( HFIELD hfield, LPSTR pbuf );
  311. int     WINAPI field_phys_to_log( HFIELD hfield, LPSTR pbuf );
  312. int     WINAPI field_set_text( HFIELD hfield, LPSTR pbuf, BOOL physical );
  313. void    WINAPI field_unlock( HFIELD hfield );
  314.  
  315. /*---------------------------------------------------------------------------*/
  316.  
  317. /* form functions */
  318.  
  319. HFORM  WINAPI form_begin( HWND hDlg, DWORD features, PERRFUNC perror_func );
  320. int    WINAPI form_cancel( HFORM hform );
  321. int    WINAPI form_end( HFORM hform );
  322. BOOL   WINAPI form_exists( HFORM hform );
  323. HFORM  WINAPI form_get_from_hdlg( HWND hDlg );
  324. HWND   WINAPI form_get_hdlg( HFORM hform );
  325. BOOL   WINAPI form_has_changed( HFORM hform );
  326. BOOL   WINAPI form_in_error_cond( HFORM hform );
  327. BOOL   WINAPI form_is_cancelled( HFORM hform );
  328. int    WINAPI form_load( HFORM hform );
  329. LPFORM WINAPI form_lock( HFORM hform );
  330. int    WINAPI form_ok( HFORM hform );
  331. int    WINAPI form_save( HFORM hform );
  332. int    WINAPI form_set_enable_link( HFORM hform, HANDLE hcontrol,
  333.                                     DWORD condition, int ctrl_id,
  334.                                     BOOL enable );
  335. int    WINAPI form_set_help( HFORM hform, LPSTR help_file_name,
  336.                              DWORD help_context );
  337. void   WINAPI form_unlock( HFORM hform );
  338. HFIELD WINAPI form_validate( HFORM hform );
  339.  
  340. /*---------------------------------------------------------------------------*/
  341.  
  342. /* generic control functions */
  343.  
  344. HANDLE WINAPI generic_define( HFORM hform, int ctrl_id, DWORD help_context );
  345.  
  346. /*---------------------------------------------------------------------------*/
  347.  
  348. /* key status message functions */
  349.  
  350. int WINAPI keystat_define( HFORM hform, int ctrl_id, int which,
  351.                            LPSTR onmsg, LPSTR offmsg );
  352.  
  353. /*---------------------------------------------------------------------------*/
  354.  
  355. /* string manipulation functions */
  356.  
  357. int  WINAPI str_delete_char( LPSTR pstr, int ch );
  358. void WINAPI str_insert_char( LPSTR pstr, int ch, int offs );
  359. BOOL WINAPI str_is_blank( LPSTR pstr );
  360. BOOL WINAPI str_is_value_zero( LPSTR pstr );
  361. void WINAPI str_trim_spaces( LPSTR pstr );
  362.  
  363. #if defined(__cplusplus)
  364.     }
  365. #endif
  366.  
  367. #endif  /* __WEDL_H */
  368.  
  369.